package com.zxb.core.util;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
 * @author Zxb
 */
public class JsonUtil {
	public static final ObjectMapper OM = new ObjectMapper();

	static {
		// 接受不区分大小写的属性
		OM.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
        // 反序列化忽略未知字段
		OM.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
	}

	public static ObjectNode on() {
		return OM.createObjectNode();
	}

	public static ArrayNode an() {
		return OM.createArrayNode();
	}
}
